package com.example.friend.controller;


import com.example.core.controller.BaseController;
import com.example.core.domain.R;
import com.example.friend.annotation.CheckUserStatus;
import com.example.friend.domain.dto.UserSubmitDTO;
import com.example.friend.domain.vo.QuestionResult;
import com.example.friend.service.IUserSubmitService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/question")
@Tag(name = "用户题目API")
public class UserQuestionController extends BaseController {

    @Autowired
    private IUserSubmitService userQuestionService;

    @Operation(summary = "题目提交")
    @PostMapping("/submit")
    @CheckUserStatus
    public R<Void> submit(@RequestBody UserSubmitDTO userSubmitDTO) {
        return toAjax(userQuestionService.submit(userSubmitDTO));
    }

    @Operation(summary = "题目结果查询")
    @GetMapping("/exe/result")
    public R<QuestionResult> questionResult(Long examId, Long questionId, String currentTime) {
        QuestionResult questionResult = userQuestionService.questionResult(examId, questionId, currentTime);
        return R.ok(questionResult);
    }
}
